﻿Imports StreamerMatch.User32Wrappers
Imports System.Runtime.InteropServices

Public Class StreamerMatch
#Region "variables"
    Public Shared moveEnabled As Boolean = False
    Public Shared plr1Score As String = "0"
    Public Shared plr2Score As String = "0"
    Private Const WM_NCLBUTTONDOWN As Integer = &HA1S
    Private Const HTCAPTION As Integer = 2
    Public Shared activePic As ImageList
    Public Shared tempName As String = ""
    Private Shared SRCCOPY As Integer = &HCC0020
    Private _InitialStyle As Integer
    Dim WithEvents OpagueShortcut As Shortcut
    Dim WithEvents HideShortcut As Shortcut
    Dim WithEvents FocusShortcut As Shortcut
    Dim clickthrough As Boolean = False
    Dim hidden As Boolean = False
    Dim mydefaultfont As Font
#End Region

#Region "Load / Close / refresh"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        mydefaultfont = lblplr1.Font
        _InitialStyle = GetWindowLong(Me.Handle, GWL.ExStyle)
        If My.Settings.mainFormPosition.X = 0 And My.Settings.mainFormPosition.Y = 0 Then
            My.Settings.mainFormPosition = New Point(((Screen.PrimaryScreen.Bounds.Width - 693) / 2), 1)
        End If
        Me.Location = My.Settings.mainFormPosition
        OpagueShortcut = Shortcut.Create(Shortcut.Modifier.Ctrl Or Shortcut.Modifier.Alt, Keys.F12)
        HideShortcut = Shortcut.Create(Shortcut.Modifier.Ctrl Or Shortcut.Modifier.Alt, Keys.F11)
        FocusShortcut = Shortcut.Create(Shortcut.Modifier.Ctrl Or Shortcut.Modifier.Alt, Keys.F10)
        applySettings()

        If Not My.Settings.changelogVersion.Equals("v" + My.Application.Info.Version.ToString.Substring(0, My.Application.Info.Version.ToString.LastIndexOf(".")).ToString) Then
            My.Settings.changelogVersion = "v" + My.Application.Info.Version.ToString.Substring(0, My.Application.Info.Version.ToString.LastIndexOf(".")).ToString
            Dim f As New Changelog
            f.Show()
        End If

    End Sub

    Private Sub applySettings()
        iconType()
        colorType()
        locationType() 'also runs generateMenuItems()
        locEnabled()
        matchUp()
        scoreClick()
        scoreType()
        Me.Refresh()
    End Sub

    Private Sub CloseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseToolStripMenuItem.Click
        If MessageBox.Show("Do you really want to close?", "Close?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
            Me.Close()
        End If
    End Sub

    Private Sub ContextMenuStrip1_Closed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripDropDownClosedEventArgs) Handles ContextMenuStrip1.Closed
        Me.Refresh()
    End Sub

    Private Sub generateMenuItems()
        'race menus
        Dim oNewToolStripItem2 As New ToolStripMenuItem
        oNewToolStripItem2.Text = "Terran"
        oNewToolStripItem2.Tag = "t"
        oNewToolStripItem2.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.T), System.Windows.Forms.Keys)
        AddHandler oNewToolStripItem2.Click, AddressOf player3race_Click
        Player3ToolStripMenuItem.DropDownItems.Add(oNewToolStripItem2)

        Dim oNewToolStripItem3 As New ToolStripMenuItem
        oNewToolStripItem3.Text = "Protoss"
        oNewToolStripItem3.Tag = "p"
        oNewToolStripItem3.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.P), System.Windows.Forms.Keys)
        AddHandler oNewToolStripItem3.Click, AddressOf player3race_Click
        Player3ToolStripMenuItem.DropDownItems.Add(oNewToolStripItem3)

        Dim oNewToolStripItem4 As New ToolStripMenuItem
        oNewToolStripItem4.Text = "Zerg"
        oNewToolStripItem4.Tag = "z"
        oNewToolStripItem4.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys)
        AddHandler oNewToolStripItem4.Click, AddressOf player3race_Click
        Player3ToolStripMenuItem.DropDownItems.Add(oNewToolStripItem4)

        Dim roNewToolStripItem3 As New ToolStripMenuItem
        roNewToolStripItem3.Text = "Random"
        roNewToolStripItem3.Tag = "r"
        roNewToolStripItem3.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.R), System.Windows.Forms.Keys)
        AddHandler roNewToolStripItem3.Click, AddressOf player3race_Click
        Player3ToolStripMenuItem.DropDownItems.Add(roNewToolStripItem3)

        Dim oNewToolStripItem5 As New ToolStripMenuItem
        oNewToolStripItem5.Text = "Terran"
        oNewToolStripItem5.Tag = "t"
        oNewToolStripItem5.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.T), System.Windows.Forms.Keys)
        AddHandler oNewToolStripItem5.Click, AddressOf player4race_Click
        Player4ToolStripMenuItem.DropDownItems.Add(oNewToolStripItem5)

        Dim oNewToolStripItem6 As New ToolStripMenuItem
        oNewToolStripItem6.Text = "Protoss"
        oNewToolStripItem6.Tag = "p"
        oNewToolStripItem6.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.P), System.Windows.Forms.Keys)
        AddHandler oNewToolStripItem6.Click, AddressOf player4race_Click
        Player4ToolStripMenuItem.DropDownItems.Add(oNewToolStripItem6)

        Dim oNewToolStripItem7 As New ToolStripMenuItem
        oNewToolStripItem7.Text = "Zerg"
        oNewToolStripItem7.Tag = "z"
        oNewToolStripItem7.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.Z), System.Windows.Forms.Keys)
        AddHandler oNewToolStripItem7.Click, AddressOf player4race_Click
        Player4ToolStripMenuItem.DropDownItems.Add(oNewToolStripItem7)

        Dim roNewToolStripItem4 As New ToolStripMenuItem
        roNewToolStripItem4.Text = "Random"
        roNewToolStripItem4.Tag = "r"
        roNewToolStripItem4.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.R), System.Windows.Forms.Keys)
        AddHandler roNewToolStripItem4.Click, AddressOf player4race_Click
        Player4ToolStripMenuItem.DropDownItems.Add(roNewToolStripItem4)

        'color menus
        Dim oNewToolStripclrr1 As New ToolStripMenuItem
        oNewToolStripclrr1.Text = "Red"
        oNewToolStripclrr1.Tag = "3red"
        oNewToolStripclrr1.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D1), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr1.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr1)

        Dim oNewToolStripclrr2 As New ToolStripMenuItem
        oNewToolStripclrr2.Text = "Blue"
        oNewToolStripclrr2.Tag = "3blue"
        oNewToolStripclrr2.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D2), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr2.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr2)

        Dim oNewToolStripclrr3 As New ToolStripMenuItem
        oNewToolStripclrr3.Text = "Teal"
        oNewToolStripclrr3.Tag = "3teal"
        oNewToolStripclrr3.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D3), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr3.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr3)

        Dim oNewToolStripclrr4 As New ToolStripMenuItem
        oNewToolStripclrr4.Text = "Purple"
        oNewToolStripclrr4.Tag = "3purple"
        oNewToolStripclrr4.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D4), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr4.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr4)

        Dim oNewToolStripclrr5 As New ToolStripMenuItem
        oNewToolStripclrr5.Text = "Yellow"
        oNewToolStripclrr5.Tag = "3yellow"
        oNewToolStripclrr5.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D5), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr5.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr5)

        Dim oNewToolStripclrr6 As New ToolStripMenuItem
        oNewToolStripclrr6.Text = "Orange"
        oNewToolStripclrr6.Tag = "3orange"
        oNewToolStripclrr6.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D6), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr6.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr6)

        Dim oNewToolStripclrr7 As New ToolStripMenuItem
        oNewToolStripclrr7.Text = "Green"
        oNewToolStripclrr7.Tag = "3green"
        oNewToolStripclrr7.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D7), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr7.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr7)

        Dim oNewToolStripclrr8 As New ToolStripMenuItem
        oNewToolStripclrr8.Text = "Pink"
        oNewToolStripclrr8.Tag = "3pink"
        oNewToolStripclrr8.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D8), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr8.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr8)

        Dim oNewToolStripclrr12 As New ToolStripMenuItem
        oNewToolStripclrr12.Text = "Red"
        oNewToolStripclrr12.Tag = "4red"
        oNewToolStripclrr12.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D1), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr12.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr12)

        Dim oNewToolStripclrr22 As New ToolStripMenuItem
        oNewToolStripclrr22.Text = "Blue"
        oNewToolStripclrr22.Tag = "4blue"
        oNewToolStripclrr22.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D2), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr22.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr22)

        Dim oNewToolStripclrr32 As New ToolStripMenuItem
        oNewToolStripclrr32.Text = "Teal"
        oNewToolStripclrr32.Tag = "4teal"
        oNewToolStripclrr32.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D3), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr32.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr32)

        Dim oNewToolStripclrr42 As New ToolStripMenuItem
        oNewToolStripclrr42.Text = "Purple"
        oNewToolStripclrr42.Tag = "4purple"
        oNewToolStripclrr42.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D4), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr4.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr42)

        Dim oNewToolStripclrr52 As New ToolStripMenuItem
        oNewToolStripclrr52.Text = "Yellow"
        oNewToolStripclrr52.Tag = "4yellow"
        oNewToolStripclrr52.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D5), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr52.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr52)

        Dim oNewToolStripclrr62 As New ToolStripMenuItem
        oNewToolStripclrr62.Text = "Orange"
        oNewToolStripclrr62.Tag = "4orange"
        oNewToolStripclrr62.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D6), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr62.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr62)

        Dim oNewToolStripclrr72 As New ToolStripMenuItem
        oNewToolStripclrr72.Text = "Green"
        oNewToolStripclrr72.Tag = "4green"
        oNewToolStripclrr72.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D7), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr72.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr72)

        Dim oNewToolStripclrr82 As New ToolStripMenuItem
        oNewToolStripclrr82.Text = "Pink"
        oNewToolStripclrr82.Tag = "4pink"
        oNewToolStripclrr82.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D8), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr82.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr82)

        Dim oNewToolStripclrr821 As New ToolStripMenuItem
        oNewToolStripclrr821.Text = "White"
        oNewToolStripclrr821.Tag = "3white"
        oNewToolStripclrr821.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D9), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr821.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr821)

        Dim oNewToolStripclrr822 As New ToolStripMenuItem
        oNewToolStripclrr822.Text = "Brown"
        oNewToolStripclrr822.Tag = "3brown"
        oNewToolStripclrr822.ShortcutKeys = CType(((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D0), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr822.Click, AddressOf plrcolor_click
        Player3ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr822)

        Dim oNewToolStripclrr823 As New ToolStripMenuItem
        oNewToolStripclrr823.Text = "White"
        oNewToolStripclrr823.Tag = "4white"
        oNewToolStripclrr823.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D9), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr823.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr823)

        Dim oNewToolStripclrr824 As New ToolStripMenuItem
        oNewToolStripclrr824.Text = "Brown"
        oNewToolStripclrr824.Tag = "4brown"
        oNewToolStripclrr824.ShortcutKeys = CType(((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift) Or System.Windows.Forms.Keys.D0), System.Windows.Forms.Keys)
        AddHandler oNewToolStripclrr824.Click, AddressOf plrcolor_click
        Player4ToolStripMenuItem1.DropDownItems.Add(oNewToolStripclrr824)

        'location menus
        For ii As Integer = 1 To 4
            For i As Integer = 1 To 12
                Dim hotkeymod As Keys = Nothing
                Dim hotkeynum As Keys = Nothing
                Dim hotkey As Keys = Nothing
                If My.Settings.locHotkeyMode = 1 Then


                    If i = 3 Or i = 6 Or i = 9 Or i = 12 Then
                        If ii = 1 Then
                            hotkeymod = Keys.Control
                        ElseIf ii = 2 Then
                            hotkeymod = Keys.Alt
                            'ElseIf ii = 3 Then
                            '    hotkeymod = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift), System.Windows.Forms.Keys)
                            'ElseIf ii = 4 Then
                            '    hotkeymod = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift), System.Windows.Forms.Keys)
                        End If
                        If i = 3 Then
                            hotkeynum = Keys.NumPad6
                        ElseIf i = 6 Then
                            hotkeynum = Keys.NumPad2
                        ElseIf i = 9 Then
                            hotkeynum = Keys.NumPad4
                        ElseIf i = 12 Then
                            hotkeynum = Keys.NumPad8
                        End If
                    End If
                ElseIf My.Settings.locHotkeyMode = 2 Then
                    If ii = 1 Then
                        hotkeymod = Keys.Control
                    ElseIf ii = 2 Then
                        hotkeymod = Keys.Alt
                        'ElseIf ii = 3 Then
                        '    hotkeymod = CType((System.Windows.Forms.Keys.Control Or System.Windows.Forms.Keys.Shift), System.Windows.Forms.Keys)
                        'ElseIf ii = 4 Then
                        '    hotkeymod = CType((System.Windows.Forms.Keys.Alt Or System.Windows.Forms.Keys.Shift), System.Windows.Forms.Keys)
                    End If
                    If i = 1 Then
                        hotkeynum = Keys.NumPad1
                    ElseIf i = 2 Then
                        hotkeynum = Keys.NumPad2
                    ElseIf i = 3 Then
                        hotkeynum = Keys.NumPad3
                    ElseIf i = 4 Then
                        hotkeynum = Keys.NumPad4
                    ElseIf i = 5 Then
                        hotkeynum = Keys.NumPad5
                    ElseIf i = 6 Then
                        hotkeynum = Keys.NumPad6
                    ElseIf i = 7 Then
                        hotkeynum = Keys.NumPad7
                    ElseIf i = 8 Then
                        hotkeynum = Keys.NumPad8
                    ElseIf i = 9 Then
                        hotkeynum = Keys.NumPad9
                    ElseIf i = 10 Then
                        hotkeynum = Keys.Divide
                    ElseIf i = 11 Then
                        hotkeynum = Keys.Multiply
                    ElseIf i = 12 Then
                        hotkeynum = Keys.Subtract
                    End If
                End If

                If Not hotkeymod = Nothing Then
                    hotkey = CType((hotkeymod Or hotkeynum), Keys)
                End If
                Dim tool1 As New ToolStripMenuItem
                tool1.Text = i.ToString
                tool1.Tag = ii.ToString + i.ToString
                tool1.ShortcutKeys = hotkey
                AddHandler tool1.Click, AddressOf location_click
                If ii = 1 Then
                    Player1ToolStripMenuItem4.DropDownItems.Add(tool1)
                ElseIf ii = 2 Then
                    Player2ToolStripMenuItem4.DropDownItems.Add(tool1)
                ElseIf ii = 3 Then
                    Player3ToolStripMenuItem3.DropDownItems.Add(tool1)
                ElseIf ii = 4 Then
                    Player4ToolStripMenuItem3.DropDownItems.Add(tool1)
                End If

            Next
        Next

        RedToolStripMenuItem.Tag = "1red"
        BlueToolStripMenuItem.Tag = "1blue"
        TealToolStripMenuItem.Tag = "1teal"
        PurpleToolStripMenuItem.Tag = "1purple"
        YellowToolStripMenuItem.Tag = "1yellow"
        OrangeToolStripMenuItem.Tag = "1orange"
        GreenToolStripMenuItem.Tag = "1green"
        PinkToolStripMenuItem.Tag = "1pink"
        RedToolStripMenuItem1.Tag = "2red"
        BlueToolStripMenuItem1.Tag = "2blue"
        TealToolStripMenuItem1.Tag = "2teal"
        PurpleToolStripMenuItem1.Tag = "2purple"
        YellowToolStripMenuItem1.Tag = "2yellow"
        OrangeToolStripMenuItem1.Tag = "2orange"
        GreenToolStripMenuItem1.Tag = "2green"
        PinkToolStripMenuItem1.Tag = "2pink"
        WhiteToolStripMenuItem.Tag = "1white"
        WhiteToolStripMenuItem1.Tag = "2white"
        BrownToolStripMenuItem.Tag = "1brown"
        BrownToolStripMenuItem1.Tag = "2brown"

        TextIncreaseToolStripMenuItem.ShortcutKeys = CType(Keys.Control Or Keys.Up, Keys)
        TextDecreaseToolStripMenuItem.ShortcutKeys = CType(Keys.Control Or Keys.Down, Keys)
        TextIncreaseToolStripMenuItem.ShowShortcutKeys = True
        TextDecreaseToolStripMenuItem.ShowShortcutKeys = True

        'hide them
        If My.Settings.matchUp = 1 Then
            toggleMenuItems2v2(False)
        End If
    End Sub

    Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem1.Click
        Dim f As New AboutBox1
        f.Show()
    End Sub
#End Region

#Region "Races"
    Private Sub ProtossToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProtossToolStripMenuItem.Click
        Button1.BackgroundImage = activePic.Images.Item(0)
        addRaceToPlayer(lblplr1.Text, "p")
    End Sub

    Private Sub TerranToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TerranToolStripMenuItem.Click
        Button1.BackgroundImage = activePic.Images.Item(1)
        addRaceToPlayer(lblplr1.Text, "t")
    End Sub

    Private Sub ZergToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZergToolStripMenuItem.Click
        Button1.BackgroundImage = activePic.Images.Item(2)
        addRaceToPlayer(lblplr1.Text, "z")
    End Sub

    Private Sub ProtossToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProtossToolStripMenuItem1.Click
        Button2.BackgroundImage = activePic.Images.Item(0)
        addRaceToPlayer(lblplr2.Text, "p")
    End Sub

    Private Sub TerranToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TerranToolStripMenuItem1.Click
        Button2.BackgroundImage = activePic.Images.Item(1)
        addRaceToPlayer(lblplr2.Text, "t")
    End Sub

    Private Sub ZergToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZergToolStripMenuItem1.Click
        Button2.BackgroundImage = activePic.Images.Item(2)
        addRaceToPlayer(lblplr2.Text, "z")
    End Sub

    Private Sub player1race_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If sender.Tag = "p" Then
            Button1.BackgroundImage = activePic.Images.Item(0)
        ElseIf sender.Tag = "t" Then
            Button1.BackgroundImage = activePic.Images.Item(1)
        ElseIf sender.Tag = "z" Then
            Button1.BackgroundImage = activePic.Images.Item(2)
        ElseIf sender.Tag = "r" Then
            Button1.BackgroundImage = activePic.Images.Item(3)
        End If
    End Sub

    Private Sub player2race_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If sender.Tag = "p" Then
            Button2.BackgroundImage = activePic.Images.Item(0)
        ElseIf sender.Tag = "t" Then
            Button2.BackgroundImage = activePic.Images.Item(1)
        ElseIf sender.Tag = "z" Then
            Button2.BackgroundImage = activePic.Images.Item(2)
        ElseIf sender.Tag = "r" Then
            Button2.BackgroundImage = activePic.Images.Item(3)
        End If
    End Sub

    Private Sub player3race_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If sender.Tag = "p" Then
            Button3.BackgroundImage = activePic.Images.Item(0)
        ElseIf sender.Tag = "t" Then
            Button3.BackgroundImage = activePic.Images.Item(1)
        ElseIf sender.Tag = "z" Then
            Button3.BackgroundImage = activePic.Images.Item(2)
        ElseIf sender.Tag = "r" Then
            Button3.BackgroundImage = activePic.Images.Item(3)
        End If
        addRaceToPlayer(lblplr3.Text, sender.Tag)
    End Sub

    Private Sub player4race_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If sender.Tag = "p" Then
            Button4.BackgroundImage = activePic.Images.Item(0)
        ElseIf sender.Tag = "t" Then
            Button4.BackgroundImage = activePic.Images.Item(1)
        ElseIf sender.Tag = "z" Then
            Button4.BackgroundImage = activePic.Images.Item(2)
        ElseIf sender.Tag = "r" Then
            Button4.BackgroundImage = activePic.Images.Item(3)
        End If
        addRaceToPlayer(lblplr4.Text, sender.Tag)
    End Sub

    Private Sub Button2_BackgroundImageChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.BackgroundImageChanged
        If activePic.Equals(imgUnit) Then
            If Not Button2.BackgroundImage Is Nothing Then
                Dim tempimg As Bitmap = Button2.BackgroundImage
                tempimg.RotateFlip(RotateFlipType.RotateNoneFlipX)
                Button2.BackgroundImage = tempimg
            End If
        End If
    End Sub

    Private Sub Button4_BackgroundImageChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.BackgroundImageChanged
        If activePic.Equals(imgUnit) Then
            If Not Button4.BackgroundImage Is Nothing Then
                Dim tempimg As Bitmap = Button4.BackgroundImage
                tempimg.RotateFlip(RotateFlipType.RotateNoneFlipX)
                Button4.BackgroundImage = tempimg
            End If
        End If
    End Sub

    Private Sub RandomToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RandomToolStripMenuItem1.Click
        Button2.BackgroundImage = activePic.Images.Item(3)
    End Sub

    Private Sub RandomToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RandomToolStripMenuItem.Click
        Button1.BackgroundImage = activePic.Images.Item(3)
    End Sub
#End Region

#Region "Player names"
    Private Sub Player1ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Player1ToolStripMenuItem1.Click, lblplr1.DoubleClick
        Dim frmDialogue As New Dialog1

        If frmDialogue.ShowDialog() = DialogResult.OK Then
            lblplr1.Text = tempName
            lblplr1.Font = mydefaultfont
            For Each s As String In My.Settings.PlayerRaces
                If s.Contains(tempName) Then
                    If s.Substring(1, 1) = "p" Then
                        Button1.BackgroundImage = activePic.Images.Item(0)
                    ElseIf s.Substring(1, 1) = "t" Then
                        Button1.BackgroundImage = activePic.Images.Item(1)
                    ElseIf s.Substring(1, 1) = "z" Then
                        Button1.BackgroundImage = activePic.Images.Item(2)
                    ElseIf s.Substring(1, 1) = "r" Then
                        Button1.BackgroundImage = activePic.Images.Item(3)
                    End If
                    Exit For
                End If
            Next
            Me.Refresh()
            textFade(lblplr1)

        End If
    End Sub

    Private Sub Player2ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Player2ToolStripMenuItem1.Click, lblplr2.DoubleClick
        Dim frmDialogue As New Dialog1

        If frmDialogue.ShowDialog() = DialogResult.OK Then
            lblplr2.Text = tempName
            lblplr2.Font = mydefaultfont
            For Each s As String In My.Settings.PlayerRaces
                If s.Contains(tempName) Then
                    If s.Substring(1, 1) = "p" Then
                        Button2.BackgroundImage = activePic.Images.Item(0)
                    ElseIf s.Substring(1, 1) = "t" Then
                        Button2.BackgroundImage = activePic.Images.Item(1)
                    ElseIf s.Substring(1, 1) = "z" Then
                        Button2.BackgroundImage = activePic.Images.Item(2)
                    ElseIf s.Substring(1, 1) = "r" Then
                        Button2.BackgroundImage = activePic.Images.Item(3)
                    End If
                    Exit For
                End If
            Next
            Me.Refresh()
            textFade(lblplr2)
        End If
    End Sub

    Private Sub plrname_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Player3ToolStripMenuItem2.Click, Player4ToolStripMenuItem2.Click, lblplr3.DoubleClick, lblplr4.DoubleClick
        Dim frmDialogue As New Dialog1

        If frmDialogue.ShowDialog() = DialogResult.OK Then
            If sender.Tag = "name3" Then
                lblplr3.Text = tempName
                lblplr3.Font = mydefaultfont
                For Each s As String In My.Settings.PlayerRaces
                    If s.Contains(tempName) Then
                        If s.Substring(1, 1) = "p" Then
                            Button3.BackgroundImage = activePic.Images.Item(0)
                        ElseIf s.Substring(1, 1) = "t" Then
                            Button3.BackgroundImage = activePic.Images.Item(1)
                        ElseIf s.Substring(1, 1) = "z" Then
                            Button3.BackgroundImage = activePic.Images.Item(2)
                        ElseIf s.Substring(1, 1) = "r" Then
                            Button3.BackgroundImage = activePic.Images.Item(3)
                        End If
                        Exit For
                    End If
                Next
                textFade(lblplr3)
            ElseIf sender.Tag = "name4" Then
                lblplr4.Text = tempName
                lblplr4.Font = mydefaultfont
                textFade(lblplr4)
                For Each s As String In My.Settings.PlayerRaces
                    If s.Contains(tempName) Then
                        If s.Substring(1, 1) = "p" Then
                            Button4.BackgroundImage = activePic.Images.Item(0)
                        ElseIf s.Substring(1, 1) = "t" Then
                            Button4.BackgroundImage = activePic.Images.Item(1)
                        ElseIf s.Substring(1, 1) = "z" Then
                            Button4.BackgroundImage = activePic.Images.Item(2)
                        ElseIf s.Substring(1, 1) = "r" Then
                            Button4.BackgroundImage = activePic.Images.Item(3)
                        End If
                        Exit For
                    End If
                Next
            End If
            Me.Refresh()
        End If

    End Sub
#End Region

#Region "Player score"
    Private Sub Player1ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Player1ToolStripMenuItem2.Click, lblScoreplr1.DoubleClick, lblScoreOnelbl.DoubleClick
        Dim frmDialogue As New Dialog3
        If frmDialogue.ShowDialog() = DialogResult.OK Then
            If My.Settings.scoreMode = 1 Then
                lblScoreplr1.Text = plr1Score
                textFade(lblScoreplr1)
            Else
                lblScoreOnelbl.Text = plr1Score
                textFade(lblScoreOnelbl)
            End If
            Me.Refresh()
        End If
    End Sub

    Private Sub Player2ToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Player2ToolStripMenuItem2.Click, lblScoreplr2.DoubleClick
        Dim frmDialogue As New Dialog4

        If frmDialogue.ShowDialog() = DialogResult.OK Then
            lblScoreplr2.Text = plr2Score
            Me.Refresh()
            textFade(lblScoreplr2)
        End If
    End Sub

    Private Sub Player11ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As Object) Handles Player11ToolStripMenuItem.MouseDown, Player11ToolStripMenuItem.Click, lblScoreplr1.MouseDown
        If Not MouseButtons.Right Then
            Try
                Dim i As Integer = lblScoreplr1.Text
                i = i + 1
                lblScoreplr1.Text = i
                textFade(lblScoreplr1)
            Catch ex As Exception
            End Try
        End If
    End Sub

    Private Sub Player21ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As Object) Handles Player21ToolStripMenuItem.MouseDown, Player21ToolStripMenuItem.Click, lblScoreplr2.MouseDown
        If Not MouseButtons.Right Then
            Try
                Dim i As Integer = lblScoreplr2.Text
                i = i + 1
                lblScoreplr2.Text = i
                textFade(lblScoreplr2)
            Catch ex As Exception
            End Try
        End If
    End Sub

    Private Sub EditToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim f As New Dialog3
        If f.DialogResult = Windows.Forms.DialogResult.OK Then
            lblScoreOnelbl.Text = plr1Score
        End If
    End Sub
#End Region

#Region "location"
    Private Sub location_click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim player As String = sender.Tag.ToString.Substring(0, 1)
        Dim loc As String = sender.Tag.ToString.Substring(1)

        If player = 1 Then
            lblplr1loc.Text = loc
        ElseIf player = 2 Then
            lblplr2loc.Text = loc
        ElseIf player = 3 Then
            lblplr3loc.Text = loc
        ElseIf player = 4 Then
            lblplr4loc.Text = loc
        End If
    End Sub

    Private Sub ShowLocationsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        locEnabled()
    End Sub

    Private Sub locEnabled()
        If My.Settings.locEnabled Then
            lblplr1loc.Visible = True
            lblplr2loc.Visible = True
            lblplr3loc.Visible = True
            lblplr4loc.Visible = True
        ElseIf My.Settings.locEnabled = False Then
            lblplr1loc.Visible = False
            lblplr2loc.Visible = False
            lblplr3loc.Visible = False
            lblplr4loc.Visible = False
        End If
    End Sub
#End Region

#Region "colors"

    Private Sub plrcolor_click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
    Handles RedToolStripMenuItem.Click, BlueToolStripMenuItem.Click, TealToolStripMenuItem.Click, _
    PurpleToolStripMenuItem.Click, YellowToolStripMenuItem.Click, OrangeToolStripMenuItem.Click, _
    GreenToolStripMenuItem.Click, PinkToolStripMenuItem.Click, RedToolStripMenuItem1.Click, _
    BlueToolStripMenuItem1.Click, TealToolStripMenuItem1.Click, PurpleToolStripMenuItem1.Click, _
    YellowToolStripMenuItem1.Click, OrangeToolStripMenuItem1.Click, GreenToolStripMenuItem1.Click, _
    PinkToolStripMenuItem1.Click, WhiteToolStripMenuItem.Click, WhiteToolStripMenuItem1.Click, BrownToolStripMenuItem.Click, BrownToolStripMenuItem1.Click
        Dim player As String = sender.Tag.ToString.Substring(0, 1)
        Dim color As String = sender.Tag.ToString.Substring(1)
        Dim usecolor As New Color

        If color = "red" Then
            usecolor = Drawing.Color.Red
        ElseIf color = "blue" Then
            usecolor = Drawing.Color.DodgerBlue
        ElseIf color = "teal" Then
            usecolor = Drawing.Color.Cyan
        ElseIf color = "purple" Then
            usecolor = Drawing.Color.Purple
        ElseIf color = "yellow" Then
            usecolor = Drawing.Color.Yellow
        ElseIf color = "orange" Then
            usecolor = Drawing.Color.Orange
        ElseIf color = "green" Then
            usecolor = Drawing.Color.Green
        ElseIf color = "pink" Then
            usecolor = Drawing.Color.Pink
        ElseIf color = "brown" Then
            usecolor = Drawing.Color.SaddleBrown
        ElseIf color = "white" Then
            usecolor = Drawing.Color.White
        End If
        If My.Settings.colorType = 1 Then
            If player = 1 Then
                lblplr1.ForeColor = usecolor
            ElseIf player = 2 Then
                lblplr2.ForeColor = usecolor
            ElseIf player = 3 Then
                lblplr3.ForeColor = usecolor
            ElseIf player = 4 Then
                lblplr4.ForeColor = usecolor
            End If
        ElseIf My.Settings.colorType = 2 Then
            If player = 1 Then
                btnplrcolor1.Visible = True
                btnplrcolor1.BackColor = usecolor
            ElseIf player = 2 Then
                btnplrcolor2.Visible = True
                btnplrcolor2.BackColor = usecolor
            ElseIf player = 3 Then
                btnplrcolor3.Visible = True
                btnplrcolor3.BackColor = usecolor
            ElseIf player = 4 Then
                btnplrcolor4.Visible = True
                btnplrcolor4.BackColor = usecolor
            End If
        End If

    End Sub

#End Region

#Region "Settings"
    'races
    Private Sub iconType()
        If My.Settings.iconType = 1 Then
            activePic = imgUnit
        ElseIf My.Settings.iconType = 2 Then
            activePic = imgIcon
        End If
    End Sub

    Private Sub scoreType()
        If My.Settings.scoreMode = 1 Then
            lblScoreOnelbl.Visible = False
            TableLayoutPanel2.Visible = True
            Player1ToolStripMenuItem2.Text = "Player 1"
            Player2ToolStripMenuItem2.Visible = True
            Player11ToolStripMenuItem.Visible = True
            Player21ToolStripMenuItem.Visible = True
            Player2ToolStripMenuItem2.Enabled = True
            Player11ToolStripMenuItem.Enabled = True
            Player21ToolStripMenuItem.Enabled = True
            lblScoreOnelbl.Text = "Best of 1"
        ElseIf My.Settings.scoreMode = 2 Then
            lblScoreOnelbl.Visible = True
            TableLayoutPanel2.Visible = False
            Player1ToolStripMenuItem2.Text = "Edit"
            Player2ToolStripMenuItem2.Visible = False
            Player11ToolStripMenuItem.Visible = False
            Player21ToolStripMenuItem.Visible = False
            Player2ToolStripMenuItem2.Enabled = False
            Player11ToolStripMenuItem.Enabled = False
            Player21ToolStripMenuItem.Enabled = False
            lblScoreOnelbl.Text = "Best of 1"
        End If
    End Sub

    'colors
    Private Sub colorType()
        If My.Settings.colorType = 1 Then
            btnplrcolor1.Visible = False
            btnplrcolor2.Visible = False
            btnplrcolor3.Visible = False
            btnplrcolor4.Visible = False
            lblplr1.TextAlign = ContentAlignment.MiddleCenter
            lblplr3.TextAlign = ContentAlignment.MiddleCenter
            lblplr2.TextAlign = ContentAlignment.MiddleCenter
            lblplr4.TextAlign = ContentAlignment.MiddleCenter
        ElseIf My.Settings.colorType = 2 Then
            btnplrcolor1.Visible = False
            btnplrcolor2.Visible = False
            btnplrcolor3.Visible = False
            btnplrcolor4.Visible = False
            lblplr1.ForeColor = lblScoreplr1.ForeColor
            lblplr2.ForeColor = lblScoreplr1.ForeColor
            lblplr3.ForeColor = lblScoreplr1.ForeColor
            lblplr4.ForeColor = lblScoreplr1.ForeColor
            lblplr1.TextAlign = ContentAlignment.MiddleLeft
            lblplr3.TextAlign = ContentAlignment.MiddleLeft
            lblplr2.TextAlign = ContentAlignment.MiddleRight
            lblplr4.TextAlign = ContentAlignment.MiddleRight
        End If
    End Sub

    'scores
    Private Sub scoreClick()
        Select Case My.Settings.scoreClick
            Case True
                RemoveHandler lblScoreplr1.MouseDown, AddressOf Player11ToolStripMenuItem_Click
                RemoveHandler lblScoreplr2.MouseDown, AddressOf Player21ToolStripMenuItem_Click
                
                AddHandler lblScoreplr1.MouseDown, AddressOf Player11ToolStripMenuItem_Click
                AddHandler lblScoreplr2.MouseDown, AddressOf Player21ToolStripMenuItem_Click
            Case False
                RemoveHandler lblScoreplr1.MouseDown, AddressOf Player11ToolStripMenuItem_Click
                RemoveHandler lblScoreplr2.MouseDown, AddressOf Player21ToolStripMenuItem_Click

                AddHandler lblScoreplr1.MouseDown, AddressOf Form1_MouseDown
                AddHandler lblScoreplr2.MouseDown, AddressOf Form1_MouseDown
        End Select

    End Sub

    'locations
    Private Sub locationType()
        For Each t As ToolStripMenuItem In LocationToolStripMenuItem.DropDownItems
            t.DropDownItems.Clear()
        Next
        generateMenuItems()
        Me.Refresh()
    End Sub

    'moving
    Private Sub Form1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown, _
    lblplr1.MouseDown, lblplr2.MouseDown, lblplr3.MouseDown, lblplr4.MouseDown, btnplrcolor1.MouseDown, btnplrcolor2.MouseDown, _
    btnplrcolor3.MouseDown, btnplrcolor4.MouseDown, TableLayoutPanel1.MouseDown, lblScoreplr2.MouseDown, Button1.MouseDown, _
    Button2.MouseDown, Button3.MouseDown, Button4.MouseDown, lblScoreplr1.MouseDown, lblhyphen.MouseDown, TableLayoutPanel2.MouseDown, _
    FlowLayoutPanel1.MouseDown, Me.MouseDown, lblScoreOnelbl.MouseDown, TableLayoutPanel1.MouseDown, PictureBox1.MouseDown
        If moveEnabled Then
            Me.Capture = False
            Me.lblplr1.Capture = False
            Me.lblplr2.Capture = False
            Me.TableLayoutPanel1.Capture = False
            Me.Button1.Capture = False
            Me.Button2.Capture = False
            Me.btnplrcolor1.Capture = False
            Me.btnplrcolor2.Capture = False
            Me.PictureBox1.Capture = False
            Me.lblhyphen.Capture = False
            Me.lblScoreOnelbl.Capture = False
            If Not My.Settings.scoreClick Then
                Me.lblScoreplr1.Capture = False
                Me.lblScoreplr2.Capture = False
            End If
            Dim msg As Message = Message.Create(Me.Handle, WM_NCLBUTTONDOWN, New IntPtr(HTCAPTION), IntPtr.Zero)
            Me.DefWndProc(msg)
        End If
    End Sub

    Private Sub StandardPositionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StandardPositionToolStripMenuItem1.Click
        Me.Location = New Point(((Screen.PrimaryScreen.Bounds.Width - 693) / 2), 1)
        Me.Refresh()
    End Sub

    Private Sub MoveableToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MovableToolStripMenuItem1.CheckedChanged
        If MovableToolStripMenuItem1.Checked Then
            moveEnabled = True
        Else
            moveEnabled = False
        End If
    End Sub

    'matchup
    Private Sub V1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles V1ToolStripMenuItem1.Click
        My.Settings.matchUp = 1
        Me.Height = 50
        V2ToolStripMenuItem1.Checked = False
        V1ToolStripMenuItem1.Checked = True
        lblplr3.Visible = False
        lblplr4.Visible = False
        Button1.Size = New Size(50, 50)
        Button2.Size = New Size(50, 50)
        Button3.Visible = False
        Button4.Visible = False
        Me.BackgroundImage = formBG2v2.BackgroundImage
        toggleMenuItems2v2(False)
        TableLayoutPanel1.SetRowSpan(Me.pnlIndividualScore, 1)
        TableLayoutPanel1.RowStyles.Item(0).Height = 50
        TableLayoutPanel1.ColumnStyles.Item(0).Width = 50
        TableLayoutPanel1.ColumnStyles.Item(0).Width = 50
        TableLayoutPanel1.ColumnStyles.Item(8).Width = 50
        TableLayoutPanel1.ColumnStyles.Item(8).Width = 50
        pnlIndividualScore.Anchor = AnchorStyles.Top
        btnplrcolor1.Anchor = AnchorStyles.Left
        btnplrcolor2.Anchor = AnchorStyles.Left
        lblplr1.Anchor = AnchorStyles.Left
        lblplr2.Anchor = AnchorStyles.Right
        btnplrcolor1.Margin = New Padding(0, 0, 0, 0)
        btnplrcolor2.Margin = New Padding(0, 0, 0, 0)
        lblplr1loc.Margin = New Padding(0, 0, 0, 14)
        lblplr2loc.Margin = New Padding(0, 0, 0, 14)
        Button2_BackgroundImageChanged(Me, Nothing)
        Button4_BackgroundImageChanged(Me, Nothing)
    End Sub

    Private Sub V2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles V2ToolStripMenuItem1.Click
        My.Settings.matchUp = 2
        Me.Height = 77
        V1ToolStripMenuItem1.Checked = False
        V2ToolStripMenuItem1.Checked = True
        lblplr3.Visible = True
        lblplr4.Visible = True
        Button1.Size = New Size(38, 38)
        Button2.Size = New Size(38, 38)
        Button3.Size = New Size(38, 38)
        Button4.Size = New Size(38, 38)
        Button3.Visible = True
        Button4.Visible = True
        Me.BackgroundImage = formBG1v1.BackgroundImage
        toggleMenuItems2v2(True)
        TableLayoutPanel1.SetRowSpan(Me.pnlIndividualScore, 2)
        TableLayoutPanel1.RowStyles.Item(0).Height = 38
        TableLayoutPanel1.ColumnStyles.Item(0).Width = 38
        TableLayoutPanel1.ColumnStyles.Item(0).Width = 38
        TableLayoutPanel1.ColumnStyles.Item(8).Width = 38
        TableLayoutPanel1.ColumnStyles.Item(8).Width = 38
        pnlIndividualScore.Anchor = AnchorStyles.None
        btnplrcolor1.Anchor = AnchorStyles.Bottom
        btnplrcolor2.Anchor = AnchorStyles.Bottom
        lblplr1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles)
        lblplr2.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        btnplrcolor1.Margin = New Padding(0, 3, 0, 0)
        btnplrcolor2.Margin = New Padding(0, 3, 0, 0)
        lblplr1loc.Margin = New Padding(0, 0, 0, 0)
        lblplr2loc.Margin = New Padding(0, 0, 0, 0)
        Button2_BackgroundImageChanged(Me, Nothing)
        Button4_BackgroundImageChanged(Me, Nothing)
    End Sub

    Private Sub toggleMenuItems2v2(ByVal boo As Boolean)
        Player3ToolStripMenuItem1.Visible = boo
        Player4ToolStripMenuItem1.Visible = boo
        Player3ToolStripMenuItem2.Visible = boo
        Player4ToolStripMenuItem2.Visible = boo
        Player3ToolStripMenuItem.Visible = boo
        Player4ToolStripMenuItem.Visible = boo
        Player3ToolStripMenuItem3.Visible = boo
        Player4ToolStripMenuItem3.Visible = boo

        Player3ToolStripMenuItem1.DropDownItems.Clear()
        Player4ToolStripMenuItem1.DropDownItems.Clear()
        Player3ToolStripMenuItem2.DropDownItems.Clear()
        Player4ToolStripMenuItem2.DropDownItems.Clear()
        Player3ToolStripMenuItem.DropDownItems.Clear()
        Player4ToolStripMenuItem.DropDownItems.Clear()
        Player3ToolStripMenuItem3.DropDownItems.Clear()
        Player4ToolStripMenuItem3.DropDownItems.Clear()

        If boo Then
            generateMenuItems()
        End If

    End Sub

    Private Sub matchUp()
        If My.Settings.matchUp = 1 Then
            V1ToolStripMenuItem_Click(Me, Nothing)
        ElseIf My.Settings.matchUp = 2 Then
            V2ToolStripMenuItem_Click(Me, Nothing)
        End If
    End Sub

    'clear
    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem1.Click
        lblplr1.Text = " "
        lblplr2.Text = " "
        lblplr3.Text = " "
        lblplr4.Text = " "
        Button1.BackgroundImage = Nothing
        Button2.BackgroundImage = Nothing
        Button3.BackgroundImage = Nothing
        Button4.BackgroundImage = Nothing
        lblScoreplr1.Text = 0
        lblScoreplr2.Text = 0
        Dim usecolor As Color = lblScoreplr1.ForeColor
        If My.Settings.colorType = 1 Then
            lblplr1.ForeColor = usecolor
            lblplr2.ForeColor = usecolor
            lblplr3.ForeColor = usecolor
            lblplr4.ForeColor = usecolor
        ElseIf My.Settings.colorType = 2 Then
            btnplrcolor1.Visible = False
            btnplrcolor2.Visible = False
            btnplrcolor3.Visible = False
            btnplrcolor4.Visible = False
        End If

    End Sub

    'options
    Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
        Dim f As New frmOptions
        If f.ShowDialog = Windows.Forms.DialogResult.OK Then
            applySettings()
        End If
    End Sub

    'global hotkeys
    Private Sub SetFormToTransparent()
        SetWindowLong(Me.Handle, GWL.ExStyle, _
            _InitialStyle Or WS_EX.Layered Or WS_EX.Transparent)
        For i As Integer = 0 To 100
            SetLayeredWindowAttributes(Me.Handle, 0, _
                           255 * (i / 100), LWA.ColorKey Or LWA.Alpha)
            Threading.Thread.Sleep(10)
        Next

    End Sub

    Private Sub SetFormToOpaque()
        ' Turn off the Transparent Extended Style.
        SetWindowLong(Me.Handle, GWL.ExStyle, _
                _InitialStyle Or WS_EX.Layered)

        SetLayeredWindowAttributes(Me.Handle, _
                           0, 255, LWA.ColorKey)
    End Sub

    Private Sub OpagueShortcut_Press(ByVal s As Object, ByVal e As Shortcut.HotKeyEventArgs) Handles OpagueShortcut.Press
        If clickthrough = False Then
            SetFormToTransparent()
            clickthrough = True
        Else
            SetFormToOpaque()
            clickthrough = False
        End If
    End Sub

    Private Sub HideShortcut_Press(ByVal s As Object, ByVal e As Shortcut.HotKeyEventArgs) Handles HideShortcut.Press
        If hidden = False Then
            Me.Visible = False
            hidden = True
        Else
            Me.Visible = True
            hidden = False
        End If
    End Sub

    Private Sub FocusShortcut_Press(ByVal s As Object, ByVal e As Shortcut.HotKeyEventArgs) Handles FocusShortcut.Press
        checkautfocus(Me.Handle)
    End Sub

    Private Sub checkautfocus(ByVal hWnd)
        SetForegroundWindow(hWnd)
    End Sub

    <DllImport("user32.dll")> _
    Private Shared Function SetForegroundWindow(ByVal hWnd As IntPtr) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    Private Sub HotkeyViewerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HotkeyViewerToolStripMenuItem.Click
        Dim f As New HotkeyViewer

        f.Show()
    End Sub

    'Quick set
    Private Sub QuickSetToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuickSetToolStripMenuItem.Click
        Dim f As New QuickSet
        f.Location = My.Settings.quickSetPosition
        If f.ShowDialog = Windows.Forms.DialogResult.OK Then

        End If
    End Sub

    'text size
    Private Sub TextIncreaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextIncreaseToolStripMenuItem.Click
        Dim f As Font = lblplr1.Font

        If Not f.Size.ToString = "15,75" Then
            Dim q As Font = New Font(f.FontFamily, f.Size + 1, FontStyle.Bold, GraphicsUnit.Point)
            lblplr1.Font = q
            lblplr2.Font = q
            lblplr3.Font = q
            lblplr4.Font = q
        End If
    End Sub

    Private Sub TextDecreaseToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextDecreaseToolStripMenuItem.Click
        Dim f As Font = lblplr1.Font
        Dim q As Font = New Font(f.FontFamily, f.Size - 1, FontStyle.Bold, GraphicsUnit.Point)

        lblplr1.Font = q
        lblplr2.Font = q
        lblplr3.Font = q
        lblplr4.Font = q
    End Sub

    'changelog
    Private Sub ChangelogToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangelogToolStripMenuItem.Click
        Dim f As New Changelog
        f.Show()
    End Sub

    'location
    Private Sub StreamerMatch_LocationChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LocationChanged
        My.Settings.mainFormPosition = Me.Location
    End Sub
#End Region

#Region "screenshot"
    Private Shared Function BitBlt(ByVal hdcDest As IntPtr, ByVal nXDest As Integer, ByVal nYDest As Integer, _
                                    ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As IntPtr, _
                                    ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Integer) As Boolean
    End Function

    Private Sub SaveFormToFile(ByVal sourceForm As Form)
        Dim formGraphics As Graphics = sourceForm.CreateGraphics()

        Dim bufferRect = sourceForm.ClientRectangle
        Dim buffer As Image = New Bitmap(bufferRect.Width, bufferRect.Height, formGraphics)
        Dim bufferGraphics As Graphics = Graphics.FromImage(buffer)
        bufferGraphics.CopyFromScreen(Bounds.Location, New Point(0, 0), Bounds.Size, CopyPixelOperation.SourceCopy)
        Dim formDC As IntPtr = formGraphics.GetHdc()
        Dim bufferDC As IntPtr = bufferGraphics.GetHdc()

        BitBlt(bufferDC, 0, 0, bufferRect.Width, bufferRect.Height, formDC, 0, 0, SRCCOPY)

        bufferGraphics.ReleaseHdc(bufferDC)
        formGraphics.ReleaseHdc(formDC)

        bufferGraphics.Dispose()
        formGraphics.Dispose()

        If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

            If SaveFileDialog1.FileName <> "" Then
                Dim fs As System.IO.FileStream = CType _
                   (SaveFileDialog1.OpenFile(), System.IO.FileStream)
                Select Case SaveFileDialog1.FilterIndex
                    Case 1
                        buffer.Save(fs, _
                           System.Drawing.Imaging.ImageFormat.Jpeg)
                    Case 2
                        buffer.Save(fs, _
                           System.Drawing.Imaging.ImageFormat.Bmp)
                End Select
                fs.Close()
            End If
        End If
        buffer.Dispose()
    End Sub

    Private Sub ScreenshotToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScreenshotToolStripMenuItem1.Click
        SaveFormToFile(Me)
    End Sub

    Public Sub textFade(ByVal player As Label)
        If My.Settings.textFade Then
            Dim t As Threading.Thread
            t = New Threading.Thread(AddressOf textFadeInNewThread)
            t.Start(player)
        End If
    End Sub

    Private Sub textFadeInNewThread(ByVal player As Label)
        Dim color As Color = player.ForeColor
        Dim r As Integer = color.R.GetHashCode
        Dim g As Integer = color.G.GetHashCode
        Dim b As Integer = color.B.GetHashCode
        Dim curr As Integer = 255
        Dim curg As Integer = 255
        Dim curb As Integer = 255
        For i As Integer = 0 To 255
            Dim change As Boolean = False

            If curr > r Then
                curr = curr - 1
                change = True
            End If
            If curg > g Then
                curg = curg - 1
                change = True
            End If
            If curb > b Then
                curb = curb - 1
                change = True
            End If
            If change Then
                player.ForeColor = color.FromArgb(curr, curg, curb)
                Threading.Thread.Sleep(10)
            Else
                Exit For
            End If
        Next
    End Sub
#End Region

    Private Sub addRaceToPlayer(ByVal player As String, ByVal r As String)
        For Each s As String In My.Settings.PlayerRaces
            If s.Contains(player) Then
                My.Settings.PlayerRaces.Remove(s)
                Exit For
            End If

        Next
        My.Settings.PlayerRaces.Add("#" + r + "#" + player)
    End Sub
End Class